// 自定义表单验证
export const validatorAccount = (rule, value, callback) => {
  if(value === ''){
    callback(new Error('请输入用户名'))
  }else{
    if(!/^[a-zA-Z]\w{5,19}/.test(value)){
      callback(new Error('字母开头且6-20个字符'))
    }
    callback()
  }
}

export const validatorPassword = (rule, value, callback) => {
  if(value === ''){
    callback(new Error('请输入密码'))
  }else{
    if(!/^\w{6,24}$/.test(value)){
      callback(new Error('密码是6-24个字符'))
    }
    callback()
  }
}

export const validatorPhone = (rule, value, callback) => {
  if(value === ''){
    callback(new Error('请输入手机号'))
  }else{
    if(!/^1[3-9]\d{9}$/.test(value)){
      callback(new Error('手机号格式错误'))
    }
    callback()
  }
}

export const validatorCode = (rule, value, callback) => {
  if(value === ''){
    callback(new Error('请输入验证码'))
  }else{
    if(!/^\d{6}$/.test(value)){
      callback(new Error('验证码格式错误'))
    }
    callback()
  }
}

export const validatorIsAgree  = (rule, value, callback) => {
  if(!value){
    callback(new Error('请勾选同意用户协议'))
  }else{
    callback()
  }
}


